package com.ztgf.logistics.api.cms;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.ztgf.common.constant.Result;
import com.ztgf.logistics.models.bo.LogisticsBO;
import com.ztgf.logistics.models.dto.LogisticsDTO;
import com.ztgf.logistics.models.service.ILogisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * author: chenyu.wang
 * date: 2020-05-25 10:25
 * Description:
 */
@RestController
@RequestMapping(value = "/cms/logistics")
@Api(value = "LogisticsController", tags = "物流信息接口")
@Slf4j
public class LogisticsController {


    @DubboReference
    private ILogisticsService logisticsService;


    @PostMapping("/queryPageList")
    @ApiOperation(value = "物流信息列表", notes = "物流信息列表")
    public Result<Page<LogisticsDTO>> queryPageList(@RequestBody LogisticsBO logisticsBO) {
        Wrapper<LogisticsDTO> wrapper = new EntityWrapper<>();
        if (logisticsBO.getCom() != null) {
            wrapper.eq("com", logisticsBO.getCom());
        }
        if (logisticsBO.getNu() != null) {
            wrapper.eq("nu", logisticsBO.getNu());
        }
        Page<LogisticsDTO> page = new Page<>(logisticsBO.getPageNo(), logisticsBO.getPageSize());
        page = logisticsService.selectPage(page, wrapper);
        return new Result<>(page);
    }
}
